#region Using directives

using System;

using FighterChessEngine.Enum;
using FighterChessEngine.FC_Board;
#endregion

namespace FighterChessEngine.FC_Fighter.Fighters
{
    /// <summary>
    /// Summary description for Knight.
    /// </summary>
    public class Knight : Fighter
    {
        #region Atributes
        #endregion

        #region Properties
        #endregion

        #region Methods
        public Knight() : base()
        {
            Init();
            level = 4;
        }

        public Knight(Owner owner, Square pos) : base(owner, pos)
        {
            Init();
            level = 4;
        }

        public Knight(string strKnight)
            : base(strKnight)
        {
            Init();
        }

        private void Init()
        {
            name = "Knight";
            symbol = "K";
            type = FighterType.Knight;
        }

        public override void UpdateNextPositions(Fighter[,] fighters)
        {
            base.UpdateNextPositions(fighters);

            for (int row = currentPos.Row - 2; row <= currentPos.Row + 2; row++)
                for (int col = currentPos.Col - 2; col <= currentPos.Col + 2; col++)
                {
                    // current pos + horizontal + vertial
                    if (row == currentPos.Row || col == currentPos.Col)
                        continue;
                    
                    int checkResult;
                    if (row == currentPos.Row - 1 || row == currentPos.Row + 1)
                    {
                        if (col == currentPos.Col - 2 || col == currentPos.Col + 2)
                        {
                            checkResult = CheckSquare(fighters, row, col);
                            if (checkResult == 0 || checkResult == 2)
                                arrNextPos.Add(new Square(row, col));
                        }
                    }
                    else if (row == currentPos.Row - 2 || row == currentPos.Row + 2)
                    {
                        if (col == currentPos.Col - 1 || col == currentPos.Col + 1)
                        {
                            checkResult = CheckSquare(fighters, row, col);
                            if (checkResult == 0 || checkResult == 2)
                                arrNextPos.Add(new Square(row, col));
                        }
                    }

                }
        }
        #endregion
    }
}
